package com.lineage.server.datatables.lock;

import com.lineage.server.datatables.sql.CharWeaponTimeTable;
import com.lineage.server.datatables.storage.CharWeaponStorage;
import java.sql.Timestamp;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class CharWeaponTimeReading {
  private final Lock _lock = new ReentrantLock(true);
  
  private final CharWeaponStorage _storage = (CharWeaponStorage)new CharWeaponTimeTable();
  
  private static CharWeaponTimeReading _instance;
  
  public static CharWeaponTimeReading get() {
    if (_instance == null)
      _instance = new CharWeaponTimeReading(); 
    return _instance;
  }
  
  public void load() {
    this._lock.lock();
    try {
      this._storage.load();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void addTime(int itemr_obj_id, Timestamp usertime, int magic_weapon) {
    this._lock.lock();
    try {
      this._storage.addTime(itemr_obj_id, usertime, magic_weapon);
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void updateTime(int itemr_obj_id, Timestamp usertime, int magic_weapon, int steps, int same) {
    this._lock.lock();
    try {
      this._storage.updateTime(itemr_obj_id, usertime, magic_weapon, steps, same);
    } finally {
      this._lock.unlock();
    } 
  }
}
